package com.jtjrenren.android.taxi.passenger.utils;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.view.WindowManager;

import com.library.weidget.CustomeDialog;
import com.library.utils.AppUtils;


/**
 * Created by wdl on 2015/12/11.
 */
public class UIHelper {

    public static CustomeDialog getCustomeDialog(Context context, String title, String msg, String postText, String negativeText, DialogInterface.OnClickListener postListener, DialogInterface.OnClickListener negativeListener) {
        CustomeDialog.Builder builder = new CustomeDialog.Builder(context);
        return builder.setTitle(title).setMessage(msg).setPostButton(postText, postListener).setNegativeButton(negativeText, negativeListener).create();
    }

    public static CustomeDialog getAlertDialog(Context context, String msg, DialogInterface.OnClickListener postListener, DialogInterface.OnClickListener negativeListener) {
        CustomeDialog.Builder builder = new CustomeDialog.Builder(context);
        return builder.setTitle("提示").setMessage(msg).setPostButton("确认", postListener).setNegativeButton("取消", negativeListener).create();
    }

    public static CustomeDialog getAlertDialog2(Context context, String msg, DialogInterface.OnClickListener postListener, DialogInterface.OnClickListener negativeListener) {
        CustomeDialog.Builder builder = new CustomeDialog.Builder(context);
        CustomeDialog customeDialog = builder.setTitle("提示").setMessage(msg).setPostButton("确认", postListener).setNegativeButton("取消", negativeListener).create();
        WindowManager.LayoutParams lp=customeDialog.getWindow().getAttributes();
        lp.dimAmount=0.8f;
        lp.alpha=0.8f;
        customeDialog.getWindow().setAttributes(lp);
        return customeDialog;
    }

    public static void showCallDialog(final Activity context, final String phone) {
        String desc = "拨打" + phone + "?";
        CustomeDialog dialog = UIHelper.getCustomeDialog(context, null, desc, "确认", "取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                AppUtils.callPhone(context, phone);
            }
        }, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        });

        dialog.setCanceledOnTouchOutside(true);

        dialog.show();
    }
}
